using System;
using System.Globalization;
using System.Linq;
using jSLCore.Client.Presentation.AuthorizeService;
using jSLCore.Client.Presentation.jBinding;

namespace jSLCore.Client.Presentation.Authorization.Managment
{
    public class BaseRolesToStringConverter : jChainConverter
    {
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return null;

            var roles = (Role[])value;

            var str = roles.Aggregate(string.Empty, (current, role) => current + (role.Name + ";"));
            return str;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}